#include"comm.hpp"

extern Log log;

int main()
{
    Init init;
    //获取id
    int shmid=CreatShm();
    //挂接
    char* shmadrr=(char*)shmat(shmid,NULL,0);  
    //通信code
    int fd=open(FIFO_FILE,O_RDONLY);
    if(fd<0)
    {
        log(Fatal,"processa open err:%s",strerror(errno));
        exit(3);
    }
    struct shmid_ds shmds;
    while(true)
    {
        char c;
        ssize_t s=read(fd,&c,1);
        if(s==0) break;
        else if(s<0) break;

        cout<<"client say@ "<<shmadrr<<endl;
    }
    //取消挂接
    shmdt(shmadrr);
    //销毁
    shmctl(shmid,IPC_RMID,nullptr);
    close(fd);
    return 0;
}
